<?php

/*@LICENSE@*/

/**
* A node in the genealogy tree.
* @author Thomas Quémard <thomas.quemard@gmail.com>
*/
class Clouseau_Genealogy_Node extends ArrayObject
{
    protected $_oParent;
    protected $_sName='';
    
    public function __construct()
    {
    }

    public function append(Clouseau_Genealogy_Node $o)
    {
        $o->setParent($this);
        parent::append($o);
    }

    public function clearParent()
    {
        $this->_oParent = NULL;
    }

    public function getGrandParentName()
    {
        $o = NULL;
        if (!$this->getParent() instanceof Clouseau_Genealogy)
        {
            $o = $this->getParent()->getParent();
        }
        else
        {
            $o = $this->getName();
        }
        return $o;
    }

    public function getName()
    {
        return $this->_sName;
    }

    public function getParent()
    {
        return $this->_oParent;
    }

    public function setName($s)
    {
        $this->_sName = (string)$s;
    }

    public function setParent(Clouseau_Genealogy_Node &$o)
    {        
        $this->_oParent = $o;
    }
}
